package com.crl.module.cmpRpc.parsers
{
	import com.crl.core.config.IXMLBindable;
	
	import flash.utils.getQualifiedClassName;

	public class XMLParser implements IRemoteObjectParser
	{
		public function XMLParser()
		{
		}
		
		public function parse(data:Object, mapping:Class):Object
		{
			var xml:XML=new XML(data);
			
			
			if(mapping==null){
				return xml;
			}
			
			var map:*=new mapping();
			if(map is IXMLBindable){
				(map as IXMLBindable).bindXML(xml);
				return map;
			}else{
				trace("XMLParser classMapping must is IXMLBindable but :"+getQualifiedClassName(mapping));
			}
			return xml;
		}
		
		public function get isError():Boolean
		{
			return false;
		}
		
		public function get errorMessage():String
		{
			return "xml结构不正确";
		}
	}
}